package com.tmt.im.jpa.entity;

import com.tmt.data.jpa.entity.TmtBaseEntity;
import com.tmt.data.jpa.entity.TmtBaseEntityId;
import com.tmt.im.common.enums.AddFriendMode;
import com.tmt.im.jpa.converter.StringAndAddFriendModeEnumListConverter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;

import java.io.Serial;
import java.util.List;

/**
 * 个性化参数配置表
 *
 * @Description TODO
 * @Author wuyi
 * @Date 2024/8/6 21:11
 * @Version 1.0
 **/
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "personal_setting")
@Tag(name = "personal_setting", description = "个性化参数配置表")
public class PersonalSetting extends TmtBaseEntityId {

    @Serial
    private static final long serialVersionUID = -4677585343683815567L;

    /**
     * 是否开启新消息通知
     */
    @Column(nullable = false, columnDefinition = "TINYINT(1)")
    private boolean enableNewMsgNotify = true;

    /**
     * 新消息到达是否有声音提示。
     */
    @Column(nullable = false, columnDefinition = "TINYINT(1)")
    private boolean enableSoundHint = true;

    /**
     * 新消息到达是否有震动提示。
     */
    @Column(nullable = false, columnDefinition = "TINYINT(1)")
    private boolean enableShockHint = true;

    /**
     * 是否允许申请加我为好友。
     */
    @Column(nullable = false, columnDefinition = "TINYINT(1)")
    private boolean enableAddFriend = true;

    /**
     * 添加好友时，是否需要本人审核。
     */
    @Column(nullable = false, columnDefinition = "TINYINT(1)")
    private boolean reviewOnAddingFriend = true;

    /**
     * 允许加好友的方式
     */
    @Convert(converter = StringAndAddFriendModeEnumListConverter.class)
    private List<AddFriendMode> addFriendModes;

    /**
     * 配置的拥有者
     */
    @OneToOne(cascade = {CascadeType.REFRESH}, fetch = FetchType.LAZY, optional = false)
    private IMUser owner;

}
